// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import 'babel-polyfill'
import Vue from 'vue'
import i18n from './lang'

import App from './App'
import router from './router'
//import '../theme/index.css'
//import '../element-variables.scss'
import ElementUI from 'element-ui'
/*import 'element-ui/lib/theme-default/index.css'*/
import 'element-ui/lib/theme-chalk/index.css'


import moment from 'moment'
import crypto from 'crypto'

import axios from './axios'
Vue.prototype.axios = axios;

import store from './store/index.js'
import iView from 'iview'


const config = require('../config')
Vue.prototype.uploadPath = config.dev.uploadPath;
Vue.prototype.apiPath = config.dev.apiPath;

Vue.use(ElementUI,{
    i18n: (key, value) => i18n.t(key, value)
})
Vue.use(iView)

//引入cookie支持 使用方式请百度
import VueCookies from 'vue-cookies';
Vue.use(VueCookies);

// 引用视频播放
import VideoPlayer from 'vue-video-player';
import 'video.js/dist/video-js.css';
import 'vue-video-player/src/custom-theme.css';
Vue.use(VideoPlayer);


/**
 * md5加密方法  不要修改
 * 用法：  this.$getMD5(str)
 * @param str
 * @returns {*}
 */
Vue.prototype.$getMD5 = function(str){
    const md5 = crypto.createHash("md5");
    md5.update(str);
    return md5.digest('hex');
};

/**
 * 获取字典
 * @param type 类型
 * @returns {Array}
 */
Vue.prototype.$getDictList = function (type) {
    if (!!localStorage.getItem('dictList') && !!type) {
        var dictList = JSON.parse(localStorage.getItem('dictList'));
        var list = [];
        dictList.forEach(function (e) {
			if (e.type === type) {
                list.push(e);
			}
        })
		return list;
	}
    return [];
};

/**
 * 全局date格式化过滤器  不要修改
 * 用法 {{ scope.row.createTime | date('YYYY-MM-DD HH:mm:ss') }}
 */
Vue.filter('date', function (value, format) {
    if (!value) return '';
    if (!format) return value;

    value = parseInt(value);
    return moment(value).format(format);
});

/**
 * 格式化工具
 * 用法：  this.$dateFormat(date, format);
 * @param date
 * @param format
 * @returns {*}
 */
Vue.prototype.$dateFormat = function (date, format) {
    if (!date) return '';
    if (!format) return date;
    return moment(date).format(format);
};


/* eslint-disable no-new */
new Vue({
    axios,
    store,
    router,
    i18n,
    render: h => h(App)
})
    .$mount('#app')